package org.agora.photogallery.client.view;


import org.agora.photogallery.client.model.Photo;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.DecoratorPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;

public class PhotoViewImpl implements PhotoView {
	private Panel panel = new DecoratorPanel();
	private final Image image = new Image();
	private PhotoPresenter presenter;
	private boolean hidden;
	private final Image waiting = new Image();
	;
	@Inject
	public PhotoViewImpl(){
		hide();
		image.setStyleName("mainImage");
		panel.addStyleName("photoPanel");
		waiting.setUrl("images/waiting.gif");
		waiting.setHeight("30px");
		
	}
	
	@Override 
	public void setPresenter(PhotoPresenter p ){
		presenter = p;
	}
	@Override
	public void setData(Photo photo) {
		panel.clear();
		panel.add(waiting);
		panel.clear();
		image.setUrl(photo.getUrl());
		image.setHeight(Window.getClientHeight()-200+"px");
		panel.add(image);
		show();
	}

	@Override
	public Widget asWidget() {
		return panel;
	}
	
	@Override
	public void hide(){
		panel.setVisible(false);
		
	}
	
	public void show(){
		panel.setVisible(true);
		
	}

}
